﻿using Library.Logic.Constraints;
using Library.Logic.Inference;
using System;
using TRULE = System.Linq.Expressions.Expression<System.Func<System.Linq.IQueryable<System.Linq.Expressions.Expression>, System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<System.Linq.Expressions.Expression>>>>;
using TEXPRESSION = System.Linq.Expressions.Expression;

namespace Library.Logic
{
    public class Function : IHasElementConstraintsReason
    {
        public Function(IConstraintsReason constraints)
        {
            this.elementConstraints = constraints;
        }

        IConstraintsReason elementConstraints;
        public IConstraintsReason ElementConstraints
        {
            get { return elementConstraints; }
        }
        IConstraintsReasonReadOnly IHasElementConstraintsReasonReadOnly.ElementConstraints
        {
            get { return elementConstraints; }
        }
        IConstraintsReadOnly IHasElementConstraintsReadOnly.ElementConstraints
        {
            get { return elementConstraints; }
        }
        IConstraints IHasElementConstraints.ElementConstraints
        {
            get { return elementConstraints; }
        }

        public bool Contains(object[] key, object[] value)
        {
            int key_n = key.Length;
            int value_n = value.Length;
            if ((ulong)(key_n + value_n) != ElementConstraints.InputParameters.Count) return false;
            object[] items = new object[key_n + value_n];
            Array.Copy(key, 0, items, 0, key_n);
            Array.Copy(value, 0, items, key_n, value_n);
            return ElementConstraints.Validate(items);
        }
        public bool Contains(object[] key, object[] value, out IInference argument)
        {
            int key_n = key.Length;
            int value_n = value.Length;
            if ((ulong)(key_n + value_n) != ElementConstraints.InputParameters.Count)
            {
                argument = Builtin.Inference();
                return false;
            }
            object[] items = new object[key_n + value_n];
            Array.Copy(key, 0, items, 0, key_n);
            Array.Copy(value, 0, items, key_n, value_n);
            return ElementConstraints.Validate(items, out argument);
        }
    }
}
